package configs

// ServerConfig 定义服务器配置的结构体
type ServerConfig struct {
	Name      string     `mapstructure:"name"`
	Host      string     `mapstructure:"host"`
	Port      string     `mapstructure:"port"`
	Runmode   string     `mapstructure:"runmode"`
	SecretKey string     `mapstructure:"secretKey"`
	Tls       TlsConfing `mapstructure:"tls"`
}

type TlsConfing struct {
	Enabled  bool   `mapstructure:"enable"`
	CertFile string `mapstructure:"certFile"`
	KeyFile  string `mapstructure:"keyFile"`
}

// LoggerConfig 定义日志配置的结构体
type LoggerConfig struct {
	Level           string `mapstructure:"level"`
	Dir             string `mapstructure:"dir"`
	HttpRequestLog  bool   `mapstructure:"httpRequestLog"`
	OutputToFile    bool   `mapstructure:"tofile"`
	OutputToConsole bool   `mapstructure:"toconsole"`
	MaxSize         int    `mapstructure:"maxsize"`
	MaxBackups      int    `mapstructure:"maxbackups"`
	MaxAge          int    `mapstructure:"maxage"`
	Compress        bool   `mapstructure:"compress"`
}

// DatabaseConfig 定义数据库配置的结构体
type DatabaseConfig struct {
	Default Database `mapstructure:"default"`
}

// Database 定义单个数据库连接的结构体
type Database struct {
	Link            string `mapstructure:"link"`
	Debug           bool   `mapstructure:"debug"`
	MaxIdleConns    int    `mapstructure:"maxIdleConns"`
	MaxOpenConns    int    `mapstructure:"maxOpenConns"`
	ConnMaxLifetime int    `mapstructure:"connMaxLifetime"`
}

// RedisConfig 定义 Redis 配置的结构体
type RedisConfig struct {
	Default Redis `mapstructure:"default"`
}

// Redis 定义单个 Redis 实例的结构体
type Redis struct {
	Address     string `mapstructure:"address"`
	DB          int    `mapstructure:"db"`
	Pass        string `mapstructure:"pass"`
	IdleTimeout int    `mapstructure:"idleTimeout"`
	PoolSize    int    `mapstructure:"poolSize"`
}

// EmailConfig 定义邮件配置结构体
type EmailConfig struct {
	SenderEmail string `mapstructure:"senderEmail"`
	AuthCode    string `mapstructure:"authCode"`
	SmtpServer  string `mapstructure:"smtpServer"`
	SmtpPort    int    `mapstructure:"smtpPort"`
}

type CorsConfig struct {
	AllowAll     bool     `mapstructure:"allowAll"`
	AllowOrigins []string `mapstructure:"allowOrigins"`
}

type JWTConfig struct {
	Secret string // JWT 签名
	Expire int64  // 过期时间
	Issuer string // 签发者
}
